clear
rng default
addpath /Users/tew647/mosek/9.3/toolbox/r2015aom

%% Load useful matrices
load PYX_cond 
load U_CS

%% Construct grid of parameters to check 
gran=0.5;
u01grid=0; %location normalisation [Ychosen=0, X=1]
u02grid=0; %location normalisation
u11grid=U_11_CS; %scale normalisation
u12grid=-20:gran:20; 
u22grid=-20:gran:20;  
u21grid=-20:gran:20;  
% try different values of gran and different sizes of grid hypercube as discussed in Appendix C of the paper (need powerful cluster to run the code for higher values of gran and larger sizes of hypercube)
[ca, cb, cc, cd, ce, cf] = ndgrid(u01grid, u11grid, u21grid, u02grid, u12grid, u22grid);
u01grid=ca(:);
u11grid=cb(:);
u21grid=cc(:);
u02grid=cd(:);
u12grid=ce(:);
u22grid=cf(:);
sg=size(u12grid,1);

%% Components invariant across parameter values
[equalorder, ...
Ugridreduced, sgreduced,...
id_Ugridreduced,...
s_id_gridreduced, sU_id_gridreduced,...
n_U_sets, Tcoord, indices_pairs,...
numeqconstraints,coordrowseq, fillAeq, beq]=useful_anyparam1_ind(u01grid, u11grid, u21grid,u02grid, u12grid, u22grid, sg, PYX_cond);      

%% Identified set
IdSetM_final=OneSide1_ind(u01grid, u11grid, u21grid,u02grid, u12grid, u22grid,...
                            equalorder, ...
                            Ugridreduced, sgreduced,...
                            id_Ugridreduced,...
                            s_id_gridreduced, sU_id_gridreduced,...
                            n_U_sets, Tcoord, indices_pairs,...
                            numeqconstraints,coordrowseq, fillAeq, beq);  

save('IdSetM_final.mat', 'IdSetM_final')